<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="点击" id="btn">
<h2>第<span id="num">0</span>次点击</h2>
<script>
    var btn = document.getElementById('btn');
    var num = document.getElementById('num');
    var i = 0;
    btn.onclick = function(){
        i++;
        var myObj = {page:i}

        history.pushState(myObj,null)
        num.innerHTML = i;

    }

    window.onpopstate = function(e){
        var data = e.state;
        num.innerHTML = data.page;
    }
</script>
</body>
</html>